<?php 
global $dir_tpl, $tb_fix, $temp, $anyDB;  
function RootTourName($id){
    if($id == 1){
        return "tour-nuoc-ngoai";
    }else{
        return "tour-trong-nuoc";
    }
}
$sql = "select t.tou_id, t.tou_title,t.tou_code, t.tou_category, t.tour_cat_parent_id,t.tou_root_cat_id,
                t.tou_phuongtien, t.tkh_id, t.tou_desc, t.tou_price, t.tou_begin_time,m.tme_title
            from ".$tb_fix."_tour as t
                left join ".$tb_fix."_tour_menu as m
                on m.tme_id = t.tou_category
            order by t.tou_id desc
            limit 0,14";
$q = $anyDB->query($sql);
if($anyDB->numRows($q)>0){
    $rows = $anyDB->getAll($q);
    foreach($rows as $k=>$v){
        $rows[$k]['tou_title'] = subCutString($v['tou_title'],17);
        $rows[$k]['tou_title_url'] = convertText($v['tou_title']);
        $rows[$k]['tou_cat_url'] = convertText($v['tme_title']);
        $rows[$k]['TourRootName'] = RootTourName($v['tou_root_cat_id']);
        $tourid = $v['tou_id'];
        $sql = "select mti_url from ".$tb_fix."_tour_img where tou_id = $tourid order by RAND() limit 0,1";
        $q = $anyDB->query($sql);
        if($anyDB->numRows($q)>0){
            $rImg = $anyDB->getAll($q);
            foreach($rImg as $key=>$val){
                $rows[$k]['images'] = "_showpic/phpThumb.php?src=../".$val['mti_url']."&w=140&h=93";
            }            
        }else{
            $rows[$k]['images'] = "_showpic/phpThumb.php?src=../_temp/mctourist/images/noImage.jpg&w=140&h=93";
        }
    }    
}
$temp->assign("r",$rows);            
$temp->display("$dir_tpl/blocks/home_list_tour/tpl_home_list_tour.mct"); 
?> 
